package com.eddie.auction.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Eddie
 * @date 2022/08/01 14:08
 **/
public class TypeConstant {

    private static final Map<String, Class<?>> typeMap = new HashMap<>();

    static {
        typeMap.put("BIGINT", java.lang.String.class);
        typeMap.put("INT", java.lang.Integer.class);
        typeMap.put("VARCHAR", java.lang.String.class);
        typeMap.put("TEXT", java.lang.String.class);
        typeMap.put("DATETIME", java.time.LocalDateTime.class);
        typeMap.put("DECIMAL", java.math.BigDecimal.class);
        typeMap.put("TINYINT", java.lang.Integer.class);
        typeMap.put("BIT", java.lang.Boolean.class);
        typeMap.put("TIMESTAMP", java.time.LocalDateTime.class);
    }

    private TypeConstant() {

    }

    public static void addType(String columnType, Class<?> javaType) {
        typeMap.put(columnType, javaType);
    }

    public static Class<?> getJavaType(String columnType) {
        return typeMap.get(columnType);
    }
}
